package core.objects;

import java.sql.Timestamp;
import java.util.Date;

public class UserComment extends AbstractComment {

    private int commentedOnId;

    public UserComment(int id) {
        super(id);
    }

    public UserComment(int id, int commentedOnId, int commenterId, String comment, int rating) {
        super(id);
        setUserCommentProperties(commenterId, commentedOnId, comment, rating);
        this.timestamp = new Timestamp(new Date().getTime());
    }

    public UserComment(int id, int commenterId, int commentedOnId, String comment, int rating, Timestamp timestamp) {
        super(id);
        setUserCommentProperties(commenterId, commentedOnId, comment, rating);
        this.timestamp = timestamp;
    }

    private void setUserCommentProperties(int commenterId, int commentedOnId, String comment, int rating) {
        this.commenterId = commenterId;
        this.commentedOnId = commentedOnId;
        this.comment = comment;
        this.rating = rating;
    }

    public int getCommentedOnId() {
        return commentedOnId;
    }

    public void setCommentedOnId(int commentedOn) {
        this.commentedOnId = commentedOn;
    }

    @Override
    public Object[] toObjectArray() {
        return new Object[]{ getCommentedOnId(), getCommenterId(), getRating(), getComment(), getTimestamp()};
    }
}
